package com.snnsh.kjb.lottery.web.controller;

import com.alibaba.fastjson.JSONObject;

import java.util.List;

/**
 * packageName com.snnsh.kjb.lottery.web.controller
 *
 * @author wick
 * @version V1.0.0
 * @date 2025/5/27
 */
public class BaseController {

    public JSONObject success(List<?> data) {
        JSONObject object = new JSONObject();
        object.put("status", "SUCCESS");
        object.put("rows", data);
        object.put("total", data.size());
        object.put("code", 0);
        return object;
    }

    public JSONObject success(String msg) {
        JSONObject object = new JSONObject();
        object.put("status", "SUCCESS");
        object.put("success", "true");
        object.put("msg", msg);
        object.put("code", 0);
        return object;
    }

    public JSONObject showListSuccess(List<?> data) {
        JSONObject object = new JSONObject();
        object.put("success", "SUCCESS");
        object.put("list", data);
        return object;
    }

    public <T> JSONObject successData(T data) {
        JSONObject object = new JSONObject();
        object.put("success", "true");
        object.put("data", data);
        return object;
    }

    public <T> JSONObject errorMsg(String errorMsg) {
        JSONObject object = new JSONObject();
        object.put("success", "false");
        object.put("msg", errorMsg);
        return object;
    }
}
